package com.xtx.controller.user;


import com.xtx.result.Result;
import com.xtx.service.CategoryService;
import com.xtx.vo.CategoryGoodsSubVO;
import com.xtx.vo.CategoryGoodsVo;
import com.xtx.vo.CategoryHeaderVo;
import com.xtx.vo.CategoryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/category")
@Slf4j
public class CategoryController {
    @Autowired
    private CategoryService categoryService;



    @GetMapping
    public Result<List<CategoryVo>> getCategoryById(Integer id){
        log.info("获取分类导航信息");
        List<CategoryVo> categoryVoList = categoryService.getCategoryById(id);
        return Result.success(categoryVoList);
    }
    @GetMapping("/goods")
    public Result<List<CategoryGoodsVo>> getCategoryGoodsById(Integer id){
        log.info("获取分类商品信息");
        List<CategoryGoodsVo> categoryGoodsVoList = categoryService.getCategoryGoodsById(id);
        return Result.success(categoryGoodsVoList);
    }
    @GetMapping("/sub")
    public Result<List<CategoryGoodsSubVO>> getCategorySubById(Integer id){
        log.info("获取二级分类商品信息");
        List<CategoryGoodsSubVO> categoryGoodsVoList = categoryService.getCategorySubById(id);
        return Result.success(categoryGoodsVoList);
    }
}
